﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Microsoft.VisualStudio.Data.Schema.Package.Project;
using Microsoft.Data.Schema.SchemaModel;
using TFDP.Common.T4;

namespace TFDP.Common
{
    /// <summary>
    /// This interface is used by classes that generate output for an IModelElement.
    /// </summary>
    public interface IGenerator : IDisposable
    {
        /// <summary>
        /// The type of element that is supported by this IGenerator
        /// </summary>
        Type SupportedType { get; }

        /// <summary>
        /// Initialize the generator
        /// </summary>
        /// <param name="project">The project that this generator is assigned to</param>
        void Initialize(IProcessor processor, IDatabaseProjectNode project);

        /// <summary>
        /// Generate output for the given element
        /// </summary>
        /// <param name="element">The source element</param>
        /// <returns>An IEnumerable&lt;GenerationItem&gt; containing zero or more instances that have been generated</returns>
        IEnumerable<GeneratedArtifact> Generate(IModelElement element);

        /// <summary>
        /// Raised when a template is recompiled because it has changed or if it doesn't
        /// exist in a compiled form.
        /// </summary>
        event EventHandler<TemplateRecompileEventArgs> TemplateRecompile;
    }
}
